<template>
    <div class="playlist">
        <div class="playlist-top">
            <div class="left">
                <svg class="icon" aria-hidden="true">
                    <use xlink:href="#icon-bofang2"></use>
                </svg>
                <div class="text">
                    <div class="title">播放全部</div>
                    <div class="num">(共{{playlist.tracks.length}}首)</div>
                </div>
            </div>
            <div class="btn">
                + 收藏 ({{changeValue(playlist.subscribedCount)}})
            </div>
        </div>
        <!-- 歌单 -->
        <div class="list">
            <div class="playItem" v-for="(item,index) in playlist.tracks" :key="index"  @click="setPlayIndex(index)">
                <div class="left">
                    <div class="index">{{index+1}}</div>
                    <div class="content">
                        <div class="title">{{item.name}}</div>
                        <div class="anthor">
                            <span class="tag" v-for="(tag,index) in playlist.tags" :key="index">
                                {{tag}}
                            </span>
                            <span>{{item.al.name}}</span>
                        </div>
                    </div>
                </div>
                <div class="right">
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-bofang1"></use>
                    </svg>
                    <svg class="icon" aria-hidden="true">
                        <use xlink:href="#icon-icmore"></use>
                    </svg>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import {mapMutations} from 'vuex'
    export default {
        props:['playlist'],
        setup(){
            const changeValue = (num)=>{
                let res = 0
                if(num >= 1000000000){
                    res = num/1000000000
                    res = res.toFixed(2)+ '亿'
                }else if(num >= 10000){
                    res = num/10000
                    res = res.toFixed(2)+ '万'
                }
                return res
            }
            return{
                changeValue,
                ...mapMutations(['setPlayIndex']),
            }
        },
        
    }
</script>

<style lang="less" scoped>
    .playlist{
        width: 7.5rem;
        padding: 0 0.4rem;
        background-color: #fff;
        border-top-left-radius: 0.3rem;
        border-top-right-radius: 0.3rem;
        margin-top: 0.4rem;
        .playlist-top{
            display: flex;
            justify-content: space-between;
            height: 0.8rem;
            align-items: center;
            .left{
                display: flex;
                align-items: center;
                .icon{
                    width: 0.4rem;
                    height:0.4rem;
                }
                .title{
                    font-size: 0.35rem;
                    font-weight: 900;
                }
                .num{
                    font-size: 0.28rem;
                    color: #666;
                }
                .text{
                    display: flex;
                    align-items: center;
                    margin-left: 0.25rem;
                }
            }
            .btn{
                  font-size: 0.28rem;
                  color: #fff;
                  background-color: orangered; 
                  height: 0.6rem;
                  padding: 0.1rem;
                  border-radius: 0.4rem;
            }
        }
        .list{
            margin-bottom: 60px;
            .playItem{
                display: flex;
                justify-content: space-between;
                height: 1.5rem;
                .left{
                    display: flex;
                    align-items: center;
                    color: #666;
                    .index{
                        width: 0.3rem;
                    }
                    .content{
                        margin-left: 0.4rem;
                    }
                    .title{
                        font-size: 0.20rem;
                        font-weight: 900;
                        color: #000;
                        margin-bottom: 0.1rem;
                    }
                    .tag{
                        font-size: 0.2rem;
                        color:orangered;
                        border: 1px solid orangered;
                        border-radius: 0.1rem;
                        color:#666;
                    }
                    .anthor{
                        color: #666;
                        span{
                            font-size: 0.1rem;
                        }
                    }
                }
                .right{
                    display: flex;
                    align-items: center;
                    .icon{
                        margin: 0 0.15rem;
                    }
                }
                
            }
        }
    }
</style>
